package vip.xiaonuo.smzq.modular.tkq.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.tkq.entity.TkqKcxmdj;
import vip.xiaonuo.smzq.modular.tkq.entity.vo.TkqVo;
import vip.xiaonuo.smzq.modular.tkq.service.ITkqKcxmdjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 探矿权-勘查项目登记
 *
 * @author sqq
 * @since 2024-05-23
 */
@Api(tags = "探矿权-勘查项目登记")
@RestController
@RequestMapping("/tkq/tkqKcxmdj")
@Validated
public class TkqKcxmdjController {

    @Resource
    private ITkqKcxmdjService iTkqKcxmdjService;

    /**
     * 添加探矿权-勘查项目登记
     */
    @ApiOperation("添加探矿权-勘查项目登记")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid TkqKcxmdj tkqKcxmdj) {
        iTkqKcxmdjService.save(tkqKcxmdj);
        return CommonResult.ok();
    }

    /**
     * 删除探矿权-勘查项目登记
     */
    @ApiOperation("删除探矿权-勘查项目登记")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iTkqKcxmdjService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑探矿权-勘查项目登记
     */
    @ApiOperation("编辑探矿权-勘查项目登记")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid TkqKcxmdj tkqKcxmdj) {
        iTkqKcxmdjService.updateById(tkqKcxmdj);
        return CommonResult.ok();
    }

    /**
     * 探矿权-勘查项目登记分页查询
     */
    @ApiOperation("探矿权-勘查项目登记分页查询")
    @GetMapping("/list")
    public CommonResult<Page<TkqKcxmdj>> page() {
        return CommonResult.data(iTkqKcxmdjService.page(new TkqKcxmdj()));
    }
    /**
     * 探矿权-勘查项目登记分页查询
     */
    @ApiOperation("探矿权-勘查项目登记分页查询")
    @GetMapping("/getTkqVoPage")
    public CommonResult<Page<TkqVo>> getTkqVoPage(
            @ApiParam(name = "current", value = "页数", example = "1", required = true)  @RequestParam long current,
            @ApiParam(name = "size", value = "每页数量", example = "20", required = true) @RequestParam long size,
            @ApiParam(name = "nd", value = "年度")  String nd,
            @ApiParam(name = "xzqhdm", value = "行政区划")  String xzqhdm,
            @ApiParam(name = "bglx", value = "变更类型")  String bglx
    ) {
        return CommonResult.data(iTkqKcxmdjService.getTkqVoPage(current,size,nd,xzqhdm,bglx));
    }
}
